-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
systemd: order zfs-import-* before local-fs-pre #6764
Conversation
this can also be solved by adding the proper x-systemd.* options (see "man systemd.mount" -> FSTAB) to the legacy mounts in /etc/fstab, without moving the ZFS services around.. |
@Fabian-Gruenbichler That is absolutely the right way to do this. We may want to introduce another target If this sounds like a good idea to everyone, I can code something like that up. |
Codecov Report
@@ Coverage Diff @@
## master #6764 +/- ##
=========================================
Coverage ? 74.62%
=========================================
Files ? 297
Lines ? 94357
Branches ? 0
=========================================
Hits ? 70414
Misses ? 23943
Partials ? 0
Continue to review full report at Codecov.
|
b036142
to
7d28b6e
Compare
@Fabian-Gruenbichler would you mind reviewed the updated patch which implements your suggestion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks mostly good to me, some minor nit picks only
@@ -6,6 +6,7 @@ Requires=systemd-udev-settle.service | |||
After=systemd-udev-settle.service | |||
After=cryptsetup.target | |||
Before=dracut-mount.service | |||
Before=zfs-import.target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT, the "WantedBy" below already implies a "Before", so this is probably redundant?
see "man systemd.unit":
A number of unit dependencies are automatically established, depending on unit configuration. On top of that, for units with
DefaultDependencies=yes (the default) a couple of additional dependencies are added. The precise effect of DefaultDependencies=yes
depends on the unit type (see below).
If DefaultDependencies=yes is set, units that are referenced by other units of type .target via a Wants= or Requires= dependency
might automatically gain an Before= dependency too. See systemd.target(5) for details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't DefaultDependencies=no
here, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, sorry I missed it. still not really used to the GH diff view..
man/man8/zfs.8
Outdated
finishes at boot time. For example, on machines using systemd, the mount | ||
option | ||
.Pp | ||
.Nm x-systemd.after=zfs-import.target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is only available since systemd 233, which excludes current Debian stable and Ubuntu LTS (I have not idea about RH and derived distros).
maybe use the (better fitting as well) x.systemd.requires
, which adds a Requires
and After
? a reference to man systemd.mount
might also be helpful for further reading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do this.
Description=ZFS pool import target | ||
|
||
[Install] | ||
WantedBy=zfs-mount.service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO also redundant, zfs-mount.service
already has an After=
, and the main zfs.target
already ensures that it is enabled by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zfs-mount.service
also has DefaultDependencies=no
.
I might be missing something though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but we already have a default chain of
multi-user.target
wants zfs.target
wants zfs-FOO.target/service
that makes sure all the services and targets are enabled. so we only need ordering between mount and import, if both are enabled.
zfs-mount.service
works independently of zfs-import.target
and the zfs-import-FOO
services (e.g., if your rpool has been imported but only the bootfs mounted in initramfs/dracut), it should just run after them if they are also enabled.
it's just a minor nitpick though, and the old units had that WantedBy as well, so feel free to ignore this ;) the same would IMHO also apply to zfs-share
-> zfs-mount
, which is entirely unrelated to this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are absolutely right. I'm pretty sure I was mirroring the other units dependencies, and worried that someone might enable zfs-mount
without zfs.target
. Or something quirky that the other units seemed to allow for.
I'll probably leave this as-is so as to not break anyone's (weird) existing setup, unless there's a strong opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a good time to cleanup the other unit dependencies that don't make sense. Although it should be done with two patches so we have the option of cherry-picking the minimal change back to the 0.7 releases.
zfs-import-{cache,scan}.service must complete before any mounting of filesystems can occur. To simplify this dependency, create a target that is reached After (in the systemd sense) the pool is imported. Additionally, recommend that legacy zfs mounts use the option x-systemd.requires=zfs-import.target to codify this requirement. Signed-off-by: Antonio Russo <[email protected]>
7d28b6e
to
af0dbee
Compare
I've implemented @Fabian-Gruenbichler's suggestion to the documentation. Once this is merged, I'll clean up the dependencies as suggested, and open a new pull request for discussion. |
zfs-import-{cache,scan}.service must complete before any mounting of filesystems can occur. To simplify this dependency, create a target that is reached After (in the systemd sense) the pool is imported. Additionally, recommend that legacy zfs mounts use the option x-systemd.requires=zfs-import.target to codify this requirement. Reviewed-by: Fabian Grünbichler <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Antonio Russo <[email protected]> Closes openzfs#6764
zfs-import-{cache,scan}.service must complete before any mounting of filesystems can occur. To simplify this dependency, create a target that is reached After (in the systemd sense) the pool is imported. Additionally, recommend that legacy zfs mounts use the option x-systemd.requires=zfs-import.target to codify this requirement. Reviewed-by: Fabian Grünbichler <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Antonio Russo <[email protected]> Closes openzfs#6764
zfs-import-{cache,scan}.service must complete before any mounting of filesystems can occur. To simplify this dependency, create a target that is reached After (in the systemd sense) the pool is imported. Additionally, recommend that legacy zfs mounts use the option x-systemd.requires=zfs-import.target to codify this requirement. Reviewed-by: Fabian Grünbichler <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Antonio Russo <[email protected]> Closes openzfs#6764
Cherry picked line from PR openzfs#6822, this enables the new target introduced in PR openzfs#6764. Signed-off-by: Antonio Russo <[email protected]>
Cherry picked line from PR #6822, this enables the new target introduced in PR #6764. Signed-off-by: Antonio Russo <[email protected]>
zfs-import-{cache,scan}.service must complete before any mounting of filesystems can occur. To simplify this dependency, create a target that is reached After (in the systemd sense) the pool is imported. Additionally, recommend that legacy zfs mounts use the option x-systemd.requires=zfs-import.target to codify this requirement. Reviewed-by: Fabian Grünbichler <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Antonio Russo <[email protected]> Closes openzfs#6764
zfs-import-{cache,scan}.service must complete before any mounting of filesystems can occur. To simplify this dependency, create a target that is reached After (in the systemd sense) the pool is imported. Additionally, recommend that legacy zfs mounts use the option x-systemd.requires=zfs-import.target to codify this requirement. Reviewed-by: Fabian Grünbichler <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: Antonio Russo <[email protected]> Closes openzfs#6764
Description
A new
zfs-import.target
is created, which should beAfter
any zpool import target, and should beBefore
zfs-mount.service
.The
zfs(8)
man page is updated to suggest an explicitx-systemd.after=zfs-import.target
dependency (thanks @Fabian-Gruenbichler for pointing to this systemd directive) for legacy zfs mounts.Motivation and Context
zfs-import-{cache,scan}.service
must complete before any mounting of legacy fstab ZFS filesystems can occur, creating a race between each legacy zfs.mount
andzfs-import-*.service
This patch introduces documentation and framework to simplify ordering for legacy mounts.
Ideally, only the ZFS legacy mounts would be ordered afterzfs-import-*
, but that level of fine-grained tuning will have to wait for #4943, but that PR is far more comprehensive and sophisticated. This should work now.If an installation doesn't havezpool
in its root partition, this will presumably cause a dependency loop orzfs-import-*
to fail. I don't know how significant the number of people who have thezpool
/zfs
on non-root filesystems. I also was not brave enough to try booting my system without this patch, so I don't know how critical it is.By separating out a uniform
zfs-import.target
, a great deal of flexibility is allowed to system administrators. Unlike the earlier revision of this change, there should be no backwards incompatibility.How Has This Been Tested?
I am running this on a machine that mounts several system directories via legacy fstab.
Types of changes
Checklist:
Signed-off-by
.